import { request } from "@/utils/request";

/**
 * 发放礼包
 * @param data
 */
export async function sendGift(data?: any) {
  return request<API.Response<any>>(
    "plugin.breed-game.admin.gift.gift.sendGift",
    {
      ...data,
    }
  );
}

/**
 * 获取发放历史
 * @param data
 */
export async function getSendHistory(data?: any) {
  return request<API.Response<any>>(
    "plugin.breed-game.admin.gift.gift.sendHistory",
    {
      ...data,
    }
  );
}

/**
 * 获取我的礼包
 * @param data
 */
export async function getMyGifts(data?: any) {
  return request<API.Response<any>>(
    "plugin.breed-game.admin.gift.gift.myGifts",
    {
      ...data,
    }
  );
}

/**
 * 搜索用户
 * @param data
 */
export async function searchUser(data?: any) {
  return request<API.Response<any>>(
    "plugin.breed-game.admin.gift.gift.searchUser",
    {
      ...data,
    }
  );
}

/**
 * 获取礼包剩余数量
 * @param data
 */
export async function getGiftRemaining(data?: any) {
  return request<API.Response<any>>(
    "plugin.breed-game.admin.gift.gift.remaining",
    {
      ...data,
    }
  );
}

/**
 * 领取礼包
 * @param data
 */
export async function receiveGift(data?: any) {
  return request<API.Response<any>>(
    "plugin.breed-game.admin.gift.gift.receiveGift",
    {
      ...data,
    }
  );
}

/**
 * 撤销礼包
 * @param data
 */
export async function cancelGift(data?: any) {
  return request<API.Response<any>>(
    "plugin.breed-game.admin.gift.gift.cancelGift",
    {
      ...data,
    }
  );
}

/**
 * 获取沐浴露流水记录
 * @param data
 */
export async function coinFlowList(data?: any) {
  return request<API.Response<any>>(
    "plugin.breed-game.admin.gift.gift.coinFlowList",
    {
      ...data,
    }
  );
}

/**
 * 获得微信太阳码
 *
 * @param data
 */
export async function getWxCode(data?: any) {
  return request<API.Response<any>>(
    "plugin.breed-game.admin.work.giftWeChat.getWxCode",
    {
      ...data,
    }
  );
}

// API 返回数据类型定义
declare namespace API {
  interface Response<T = any> {
    result: number;
    msg: string;
    data: T;
  }

  interface GiftInfo {
    id: number;
    sender_id: number;
    recipient_id: number;
    gift_count: number;
    gift_per_count: number;
    total_amount: number;
    created_at: number;
  }

  interface UserInfo {
    id: number;
    name: string;
    avatar: string;
  }
}
